package com.ljlobserv.demo.observe;

import com.ljlobserv.demo.Observe;
import com.ljlobserv.demo.Subject;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName：UserSubject
 * Description：
 * Create by Administrator
 * Date：2020/8/25 0025 10:58
 */
public class UserSubject extends Subject {

    /**
     * 初始化时就添加订阅对象
     */
    public UserSubject(){
        observeLinkedListList.add(new UserRecordObserve());
        observeLinkedListList.add(new ArticleObserve());
    }

    public void notifyInsert(long uid) {
        for (Observe observe : observeLinkedListList) {
            observe.insert(uid);
        }
    }

    public void notifyDelete(long uid) {
        for (Observe observe : observeLinkedListList) {
            observe.delete(uid);
        }
    }
}
